package com.tengju.user.infrastructure.persistence.mybatis.mapper.dealer.custom;

import com.tengju.user.infrastructure.persistence.mybatis.dataobject.SelfCertificationDO;
import org.apache.ibatis.annotations.*;


@Mapper
public interface SelfCertificationMapper {

    String TEMPLATE_RESULT_MAP = "w_service_self_certification";

    @Select("select * from w_service_self_certification where id_code = #{idCode} and type = #{type} and status <> #{notStatus}")
    @Results(id = TEMPLATE_RESULT_MAP,
            value = {
                    @Result(column = "id", property = "id"),
                    @Result(column = "id_code", property = "idCode"),
                    @Result(column = "account_id", property = "accountId"),
                    @Result(column = "company_name", property = "companyName"),
                    @Result(column = "company_address", property = "companyAddress"),
                    @Result(column = "company_tel", property = "companyTel"),
                    @Result(column = "company_no", property = "companyNo"),
                    @Result(column = "idcard_type", property = "idCardType"),
                    @Result(column = "idcard_name", property = "idCardName"),
                    @Result(column = "idcard_no", property = "idCardNo"),
                    @Result(column = "idcard_image", property = "idCardImage"),
                    @Result(column = "bank_no", property = "bankNo"),
                    @Result(column = "card_holder", property = "cardHolder"),
                    @Result(column = "bank_name", property = "bankName"),
                    @Result(column = "business_img", property = "businessImg"),
                    @Result(column = "licence_img", property = "licenceImg"),
                    @Result(column = "type", property = "type"),
                    @Result(column = "status", property = "status"),
                    @Result(column = "admin_id", property = "adminId"),
                    @Result(column = "remark", property = "remark"),
                    @Result(column = "check_at", property = "checkAt"),
                    @Result(column = "created_at", property = "createdAt"),
                    @Result(column = "updated_at", property = "updatedAt"),
                    @Result(column = "legal_mobile", property = "legalMobile"),
                    @Result(column = "bank_settle_no", property = "bankSettleNo")
            })
    SelfCertificationDO find(@Param("idCode") long idCode, @Param("type") int type, @Param("notStatus") int notStatus);

    @Select("select * from w_service_self_certification where id_code = #{idCode} and account_id = #{accountId} and status <> #{notStatus} limit 1")
    @ResultMap(TEMPLATE_RESULT_MAP)
    SelfCertificationDO findOne(
            @Param("idCode") long idCode,
            @Param("accountId") long accountId,
            @Param("notStatus") int notStatus);


    @Select("select * from w_service_self_certification where id_code = #{idCode} and status <> #{notStatus} limit 1")
    @ResultMap(TEMPLATE_RESULT_MAP)
    SelfCertificationDO findByIdCode(@Param("idCode") long idCode,
                                @Param("notStatus") int notStatus);
}
